using Newtonsoft.Json;
using System.Collections;
using UnityEditor;
using UnityEngine;

public static class BuildClientTool
{
    public enum ChannelType : int
    {
        /// <summary>
        /// 本地测试
        /// </summary>
        LocalDebug = 0,
        /// <summary>
        /// 外网审核
        /// </summary>
        NetCheck = 1,
        /// <summary>
        /// 外网正式
        /// </summary>
        NetRelease = 2,
    }

    public static string AppInfoFolder = Application.dataPath + "/Resources/Preset/VersionMgr/";
    private static string C_GAME_RAW_DLL = "C_GAME_RAW_DLL";

    public static void CreateAppInfo(Hashtable appInfo)
    {
        appInfo["BundleVersionCode"] = PlayerSettings.Android.bundleVersionCode;
        string configJson = JsonConvert.SerializeObject(appInfo, Formatting.None);
        FileTool.CreateFile(AppInfoFolder + "AppInfo.json", configJson);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }

    public static void BuildPlayer(string buildPath, BuildTarget buildTarget)
    {
        BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, buildPath, buildTarget, BuildOptions.CompressWithLz4);
        DebugUtil.Log("BuildApkClient:" + buildPath);
    }

    public static void SetScriptingDefineSymbols(BuildTargetGroup target, bool isRemoteDll)
    {
        if (!isRemoteDll)
        {
            PlayerSettings.SetScriptingDefineSymbolsForGroup(target, C_GAME_RAW_DLL);
        }
    }

    public static void ClearScriptingDefineSymbols(BuildTargetGroup target, bool isRemoteDll)
    {
        if (!isRemoteDll)
        {
            PlayerSettings.SetScriptingDefineSymbolsForGroup(target, null);
        }
    }
}